import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import Index from '@/views/Index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'index',
      component: Index,
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/Login.vue'),
    },

    {
      path: '/home',
      name: 'home',
      redirect: '/coursehall',
      component: () => import('../views/Home.vue'),
      children: [
        {
          path: '/coursehall',
          component: () => import('@/views/home/CourseHall.vue'),
          name: 'coursehall',
          meta: {
            title: '课程大厅',
            icon: 'el-icon-s-custom',
            roles: ['sys:user'],
          },
        },
        {
          path: '/details/:id',
          component: () => import('@/views/home/details/Details.vue'),
          name: 'details',
        },
        {
          path: '/mycourse',
          component: () => import('@/views/home/mycourse/MyCourse.vue'),
          name: 'mycourse',
          meta: {
            title: '我的课程',
            icon: 'el-icon-s-tools',
            roles: ['sys:role'],
          },
        },
        {
          path: '/myclass',
          component: () => import('@/views/home/myclass/MyClass.vue'),
          name: 'myclass',
          meta: {
            title: '我的班级',
            icon: 'el-icon-document',
            roles: ['sys:menu'],
          },
        },
        {
          path: '/analysis',
          component: () => import('@/views/home/analysis/DataAnalysis.vue'),
          name: 'menuList',
          meta: {
            title: '权限管理',
            icon: 'el-icon-document',
            roles: ['sys:menu'],
          },
        },
        {
          path: '/ranklist',
          component: () => import('@/views/home/RankList.vue'),
          name: 'ranklist',
          meta: {
            title: '权限管理',
            icon: 'el-icon-document',
            roles: ['sys:menu'],
          },
        },
        {
          path: '/competition',
          component: () => import('@/views/home/Competition.vue'),
          name: 'competition',
          meta: {
            title: '权限管理',
            icon: 'el-icon-document',
            roles: ['sys:menu'],
          },
        },
        {
          path: '/memo',
          component: () => import('@/views/home/Memo.vue'),
          name: 'memo',
        },
        {
          path: '/personal',
          component: () => import('@/views/home/personal/Personal.vue'),
          name: 'personal',
        },
      ],
    },
    {
      path: '/test',
      name: 'test',
      component: () => import('../views/Test.vue'),
    },
    {
      path: '/:pathMath(.*)*',
      name: 'NotFound',
      component: () => import('@/views/NotFound.vue'),
    },
  ],
});

export default router
